home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / plnk081.zip / pilot-link.0.8.1 / Java / Pdapilot / appointment / repeat.java < prev    next >
Encoding:
Java Source  |  1997-08-08  |  1.2 KB  |  57 lines

  1.  
  2. package Pdapilot.appointment;
  3.  
  4. public class repeat {
  5.     private int idx;
  6.     
  7.     final static private String[] names = 
  8.         { "None", "Daily", "Weekly", "MonthlyByDay", "MonthlyByDate", "Yearly" };
  9.  
  10.     public static repeat None = new repeat(0);
  11.     public static repeat Daily = new repeat(1);
  12.     public static repeat Weekly = new repeat(2);
  13.     public static repeat MonthlyByDay = new repeat(3);
  14.     public static repeat MonthlyByDate = new repeat(4);
  15.     public static repeat Yearly = new repeat(5);
  16.     
  17.     private static repeat[] objs;
  18.     
  19.     private repeat(int value) {
  20.         this.idx = value;
  21.     }
  22.     
  23.     public static repeat get(int value) {
  24.         return objs[value];
  25.     }
  26.     public static repeat get(String value) {
  27.         int i;
  28.         for(i=0;i<names.length;i++)
  29.             if (names[i].equals(value))
  30.                 return objs[i];
  31.         return null;
  32.     }
  33.     public static String[] getNames() {
  34.         return names;
  35.     }
  36.     
  37.     public String toString() {
  38.         return "repeat."+names[idx];
  39.     }
  40.         
  41.     public int getValue() {
  42.         return idx;
  43.     }
  44.     public String getName() {
  45.         return names[idx];
  46.     }
  47.  
  48.     static {
  49.         objs = new repeat[6];
  50.         objs[0] = repeat.None;
  51.         objs[1] = repeat.Daily;
  52.         objs[2] = repeat.Weekly;
  53.         objs[3] = repeat.MonthlyByDay;
  54.         objs[4] = repeat.MonthlyByDate;
  55.         objs[5] = repeat.Yearly;
  56.     }
  57. };